package com.sinvo.oa.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Base64;

/**
 * @Description
 */
public class Base64Utils {
    public static String ImageToBase64Encode(String src){
        if (src == "" || src == null) {
            return "";
        }

        File file = new File(src);
        if (!file.exists()) {
            return "";
        }

        byte [] data = null;
        try {
            FileInputStream fis = new FileInputStream(src);
            data = new byte[fis.available()];
            fis.read(data);
            fis.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return Base64.getEncoder().encodeToString(data);
    }

}
